#include <stdio.h>
#include<string.h>

struct student {
    int num;
    char name[20];
    char sex;
};

//结构体指针的练习
int main() {

    struct student s = {1001, "wangle", 'M'};
    struct student sarr[3] = {1001, "lilei", 'M', 1005, "zhangsan", 'M', 1006, "lisi", 'M'};
    struct student *p;
    printf("%d %s %c", s.num, s.name, s.sex);
    p = &s;
    printf("\n");
    //第一种方式获取成员
    printf("%d %s %c", p->num, p->name, p->sex);
    printf("\n");
    //第二种方式获取成员
    printf("%d %s %c", (*p).num, (*p).name, (*p).sex);
    p = sarr;
    printf("\n");
    //第一种输出
//    for (int i = 0; i < 3; i++) {
//        printf("%d %s %c\n",(*(p+i)).num,(*(p+i)).name,(*(p+i)).sex);
//    }
    //第二种输出
    for (; p < sarr + 3; p++) {
        printf("%d %s %c\n", p->num, p->name, p->sex);
    }
    return 0;
}
